package semaphores;

import train.Train;

public class Orange implements State { 

	private static final Orange instance = new Orange();
	
	/**
	 * Private constructor prevents instantiation from other classes
	 */
	private Orange() {}
	
	/**
	 * 
	 * @return Return the unique instance of this class
	 */
	public final static Orange getInstance() {
	    return instance;
	}
    
    /**
     * Set the train's speed 
     * 
     * @param unTrain The train which see the semaphore sem
     */
    public void actionOnTrain(Train unTrain) {
   		//As the semaphore is Orange, we divide by two the train's current speed 
   		unTrain.setCurrentSpeed(unTrain.getCurrentSpeed()/2);
    }
    
    public String toString() {
    	return "Je suis un feu orange";
    }
}